package qimao.com.edu.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import qimao.com.edu.entity.Author;
import qimao.com.edu.entity.CommenResult;
import qimao.com.edu.entity.Users;
import qimao.com.edu.service.AuthorService;
import qimao.com.edu.service.impl.AuthorServiceImpl;

@WebServlet("/admin/selectAuthorAll.do")
public class selectAuthorAllServlet extends HttpServlet{

	 private AuthorService authorService = new AuthorServiceImpl();
	    @Override
	    protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
	            throws ServletException, IOException {
	        req.setCharacterEncoding("UTF-8");
	        resp.setContentType("application/json;charset=UTF-8");
	        CommenResult cr=new CommenResult();
	        List<Author> AuthorList = authorService.AllAuthor();
	        if(AuthorList != null) {
	        	cr.setCode(200);
	        	cr.setData(AuthorList);
	        	resp.getWriter().write(cr.toJsonString());
	        }
	        System.out.println(AuthorList);
	    }
}
